<?php
namespace app\admin\middleware;

use app\common\exception\UnauthorizedException;

class PhoneExistCheck
{
    public function handle($request, \Closure $next)
    {
        // 获取用户手机号
        $phone = $request->user->phone??null;

        if ( !$phone) {
            throw new UnauthorizedException('当前功能需要用户绑定手机号', 104017);
        }

        return $next($request);
    }

}
